package net.similarsu.device.sdk.dah.struct;

import com.sun.jna.Pointer;
import com.sun.jna.Structure;

@Structure.FieldOrder({
        "dwYear"
        ,"dwMonth"
        ,"dwDay"
        ,"dwHour"
        ,"dwMinute"
        ,"dwSecond"
        ,"dwMillisecond"
        ,"dwReserved"
})
public class NET_TIME_EX extends Structure {
    public int                dwYear;                  // 年
    public int                dwMonth;                 // 月
    public int                dwDay;                   // 日
    public int                dwHour;                  // 时
    public int                dwMinute;                // 分
    public int                dwSecond;                // 秒
    public int                dwMillisecond;           // 毫秒
    public int[] dwReserved = new int[2];   // 保留字段

    public NET_TIME_EX(){
        super();
    }

    public NET_TIME_EX(Pointer pointer){
        super(pointer);
    }

    public static class ByReference extends NET_TIME_EX implements Structure.ByReference {
    };

    public static class ByValue extends NET_TIME_EX implements Structure.ByValue {
    };

    public String toString() {
        return dwYear + "/" + dwMonth + "/" + dwDay + " " + dwHour + ":" + dwMinute + ":" + dwSecond;
    }

    //用于列表中显示
    public String toStringTime()
    {
        return  String.format("%02d/%02d/%02d %02d:%02d:%02d", dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
    }

    //存储文件名使用
    public String toStringTitle()
    {
        return  String.format("Time_%02d%02d%02d_%02d%02d%02d", dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
    }
}
